#include "clientnetworkcenter.h"
#include "clientnetwork.h"
#include "singleclient.h"

ClientNetworkCenter* ClientNetworkCenter::instance()
{
	static ClientNetworkCenter* networkCenter = new ClientNetworkCenter;
	return networkCenter;
}

ClientNetwork* ClientNetworkCenter::createClientNetwork(boost::shared_ptr<SingleClient>client, SOCKET socket, const QString& realIp)
{
	ClientNetwork* newNetwork = new ClientNetwork(client, socket, realIp, client.get());
	m_ClientIdToNetwork.insert(client->getId(), newNetwork);
	return newNetwork;
}

ClientNetwork* ClientNetworkCenter::getClientNetwork(int clientId)
{
	QHash<int,ClientNetwork*>::iterator it = m_ClientIdToNetwork.find(clientId);
	if(it != m_ClientIdToNetwork.end())
	{
		return *it;
	}
	else
	{
		return NULL;
	}
}
